package com.vehiclesecure.repository;

import com.vehiclesecure.model.MaintenanceRecord;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MaintenanceRecordRepository extends MongoRepository<MaintenanceRecord, String> {
    
    List<MaintenanceRecord> findByVehicleIdOrderByReportedAtDesc(String vehicleId);
    
    List<MaintenanceRecord> findByServiceProviderIdOrderByReportedAtDesc(String serviceProviderId);
    
    List<MaintenanceRecord> findByStatusOrderByReportedAtDesc(MaintenanceRecord.MaintenanceStatus status);
    
    List<MaintenanceRecord> findByVehicleIdAndStatusOrderByReportedAtDesc(String vehicleId, MaintenanceRecord.MaintenanceStatus status);
    
    List<MaintenanceRecord> findByServiceProviderIdAndStatusOrderByReportedAtDesc(String serviceProviderId, MaintenanceRecord.MaintenanceStatus status);
    
    List<MaintenanceRecord> findByReportedByOrderByReportedAtDesc(String reportedBy);
    
    long countByServiceProviderIdAndStatus(String serviceProviderId, MaintenanceRecord.MaintenanceStatus status);
    
    long countByStatus(MaintenanceRecord.MaintenanceStatus status);
}